using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Game:MonoBehaviour {
	public static event Void GameStart;
	public static event Void GameEnd;
	public static Game instance;

	public static float baseTimeScale = 1;

	[SerializeField] bool debugMode;
	[SerializeField] LevelData firstLevel;

	public static LevelData currentLevel;

	private void Start() {
		instance=this;
		currentLevel=firstLevel;
		GameStart?.Invoke();
		if(debugMode&&Application.isEditor) return;
		GenerateNewLevel(firstLevel);
	}
	private void OnDestroy() {
		GameEnd?.Invoke();
	}

	public static void EnterNextLevel() => GenerateNewLevel(currentLevel.nextLevel);

	public static void GenerateNewLevel(LevelData level) {
		TilemapController.ClearAllFogOfWar();
		level.Generate(new GenerationParameters());
	}

	public static event Void UpdateTimeScale;
	private void FixedUpdate() {
		Time.timeScale=baseTimeScale;
		UpdateTimeScale?.Invoke();
	}

}
